<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="100px"
    >
      <el-form-item label="一级大类" prop="primaryCategory">
        <el-input
          v-model="queryParams.primaryCategory"
          placeholder="请输入一级大类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="大货款号" prop="proNo">
        <el-input
          v-model="queryParams.proNo"
          placeholder="请输入大货款号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设计款号" prop="designNumber">
        <el-input
          v-model="queryParams.designNumber"
          placeholder="请输入设计款号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="款名" prop="productName">
        <el-input
          v-model="queryParams.productName"
          placeholder="请输入款名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          :icon="!isOpen ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
          size="mini"
          @click="shouqi"
          >展开/收起</el-button
        >
      </el-form-item>
      <div v-if="isOpen">
        <el-form-item label="所属类别" prop="category">
          <el-input
            v-model="queryParams.category"
            placeholder="请输入所属类别"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物料名称" prop="materialName">
          <el-input
            v-model="queryParams.materialName"
            placeholder="请输入物料名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物料所属类别" prop="materialCategory">
          <el-input
            v-model="queryParams.materialCategory"
            placeholder="请输入物料所属类别"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="品牌" prop="brand">
          <el-input
            v-model="queryParams.brand"
            placeholder="请输入品牌"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="季节" prop="season">
          <el-input
            v-model="queryParams.season"
            placeholder="请输入季节"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="年份" prop="year">
          <el-input
            v-model="queryParams.year"
            placeholder="请输入年份"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="预计上新月份" prop="expectedMonth">
          <el-date-picker
            clearable
            v-model="queryParams.expectedMonth"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择预计上新月份"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="性别" prop="gender">
          <el-input
            v-model="queryParams.gender"
            placeholder="请输入性别"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="版型" prop="version">
          <el-input
            v-model="queryParams.version"
            placeholder="请输入版型"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="上新日期" prop="releaseDate">
          <el-date-picker
            clearable
            v-model="queryParams.releaseDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择上新日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="执行标准" prop="standard">
          <el-input
            v-model="queryParams.standard"
            placeholder="请输入执行标准"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="设计师" prop="designer">
          <el-input
            v-model="queryParams.designer"
            placeholder="请输入设计师"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物料工厂" prop="materialFactory">
          <el-input
            v-model="queryParams.materialFactory"
            placeholder="请输入物料工厂"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物料编号" prop="materialNumber">
          <el-input
            v-model="queryParams.materialNumber"
            placeholder="请输入物料编号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="成衣颜色" prop="garmentColor">
          <el-input
            v-model="queryParams.garmentColor"
            placeholder="请输入成衣颜色"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="部位" prop="part">
          <el-input
            v-model="queryParams.part"
            placeholder="请输入部位"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="用途" prop="purpose">
          <el-input
            v-model="queryParams.purpose"
            placeholder="请输入用途"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物料颜色" prop="materialColor">
          <el-input
            v-model="queryParams.materialColor"
            placeholder="请输入物料颜色"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物料色号" prop="colorCode">
          <el-input
            v-model="queryParams.colorCode"
            placeholder="请输入物料色号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="门幅" prop="width">
          <el-input
            v-model="queryParams.width"
            placeholder="请输入门幅"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="克重" prop="weight">
          <el-input
            v-model="queryParams.weight"
            placeholder="请输入克重"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="成份" prop="composition">
          <el-input
            v-model="queryParams.composition"
            placeholder="请输入成份"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="规格" prop="specification">
          <el-input
            v-model="queryParams.specification"
            placeholder="请输入规格"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物料单价" prop="materialPrice">
          <el-input
            v-model="queryParams.materialPrice"
            placeholder="请输入物料单价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单件用量" prop="unitQuantity">
          <el-input
            v-model="queryParams.unitQuantity"
            placeholder="请输入单件用量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input
            v-model="queryParams.unit"
            placeholder="请输入单位"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
      </div>
      <!-- <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item> -->
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['product:garmentMetrialList:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['product:garmentMetrialList:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['product:garmentMetrialList:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['product:garmentMetrialList:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button size="mini" plain icon="el-icon-upload" @click="daoru"
          >导入</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <div ref="tableDom">
      <el-table
        v-loading="loading"
        :maxHeight="garmentMetrialListList.length ? tableHeight : 'auto'"
        :data="garmentMetrialListList"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="ID" align="center" prop="id" />
        <el-table-column label="状态" align="center" prop="status" />
        <el-table-column
          label="一级类目"
          align="center"
          prop="primaryCategory"
        />
        <el-table-column
          label="二级类目"
          align="center"
          prop="secondCategory"
        />
        <el-table-column label="大货款号" align="center" prop="proNo" />
        <el-table-column label="设计款号" align="center" prop="designNumber" />
        <el-table-column label="三级类目" align="center" prop="category" />
        <el-table-column label="商品名称" align="center" prop="productName" />
        <el-table-column label="物料名称" align="center" prop="materialName" />
        <el-table-column
          label="物料所属类别"
          align="center"
          prop="materialCategory"
        />
        <el-table-column label="品牌" align="center" prop="brand" />
        <el-table-column label="季节" align="center" prop="season" />
        <el-table-column label="年份" align="center" prop="year" />
        <el-table-column
          label="预计上新月份"
          align="center"
          prop="expectedMonth"
          width="180"
        >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.expectedMonth, "{y}-{m}-{d}") }}</span>
          </template>
        </el-table-column>
        <el-table-column label="性别" align="center" prop="gender" />
        <el-table-column label="版型" align="center" prop="version" />
        <el-table-column
          label="上新日期"
          align="center"
          prop="releaseDate"
          width="180"
        >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.releaseDate, "{y}-{m}-{d}") }}</span>
          </template>
        </el-table-column>
        <el-table-column label="执行标准" align="center" prop="standard" />
        <el-table-column label="设计师" align="center" prop="designer" />
        <el-table-column
          label="物料工厂"
          align="center"
          prop="materialFactory"
        />
        <el-table-column
          label="物料编号"
          align="center"
          prop="materialNumber"
        />
        <el-table-column label="成衣颜色" align="center" prop="garmentColor">
          <template slot-scope="scope">
            <el-popover trigger="hover" placement="bottom" width="300">
              <el-input
                v-model="scope.row.garmentColor"
                :min-height="192"
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 24 }"
                :style="{ width: '100%' }"
                :disabled="true"
              />
              <div slot="reference">
                <span class="textname">{{ scope.row.garmentColor }} </span>
              </div>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column label="部位" align="center" prop="part" />
        <el-table-column label="用途" align="center" prop="purpose" />
        <el-table-column label="物料颜色" align="center" prop="materialColor" />
        <el-table-column label="物料色号" align="center" prop="colorCode" />
        <el-table-column label="门幅" align="center" prop="width" />
        <el-table-column label="克重" align="center" prop="weight" />
        <el-table-column label="成份" align="center" prop="composition" />
        <el-table-column label="规格" align="center" prop="specification" />
        <el-table-column label="物料单价" align="center" prop="materialPrice" />
        <el-table-column label="单件用量" align="center" prop="unitQuantity" />
        <el-table-column label="单位" align="center" prop="unit" />
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['product:garmentMetrialList:edit']"
              >修改</el-button
            >
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['product:garmentMetrialList:remove']"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改成衣物料清单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="一级大类" prop="primaryCategory">
          <el-input
            v-model="form.primaryCategory"
            placeholder="请输入一级大类"
          />
        </el-form-item>
        <el-form-item label="大货款号" prop="proNo">
          <el-input v-model="form.proNo" placeholder="请输入大货款号" />
        </el-form-item>
        <el-form-item label="设计款号" prop="designNumber">
          <el-input v-model="form.designNumber" placeholder="请输入设计款号" />
        </el-form-item>
        <el-form-item label="款名" prop="productName">
          <el-input v-model="form.productName" placeholder="请输入款名" />
        </el-form-item>
        <el-form-item label="所属类别" prop="category">
          <el-input v-model="form.category" placeholder="请输入所属类别" />
        </el-form-item>
        <el-form-item label="物料名称" prop="materialName">
          <el-input v-model="form.materialName" placeholder="请输入物料名称" />
        </el-form-item>
        <el-form-item label="物料所属类别" prop="materialCategory">
          <el-input
            v-model="form.materialCategory"
            placeholder="请输入物料所属类别"
          />
        </el-form-item>
        <el-form-item label="品牌" prop="brand">
          <el-input v-model="form.brand" placeholder="请输入品牌" />
        </el-form-item>
        <el-form-item label="季节" prop="season">
          <el-input v-model="form.season" placeholder="请输入季节" />
        </el-form-item>
        <el-form-item label="年份" prop="year">
          <el-input v-model="form.year" placeholder="请输入年份" />
        </el-form-item>
        <el-form-item label="预计上新月份" prop="expectedMonth">
          <el-date-picker
            clearable
            v-model="form.expectedMonth"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择预计上新月份"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="性别" prop="gender">
          <el-input v-model="form.gender" placeholder="请输入性别" />
        </el-form-item>
        <el-form-item label="版型" prop="version">
          <el-input v-model="form.version" placeholder="请输入版型" />
        </el-form-item>
        <el-form-item label="上新日期" prop="releaseDate">
          <el-date-picker
            clearable
            v-model="form.releaseDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择上新日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="执行标准" prop="standard">
          <el-input v-model="form.standard" placeholder="请输入执行标准" />
        </el-form-item>
        <el-form-item label="设计师" prop="designer">
          <el-input v-model="form.designer" placeholder="请输入设计师" />
        </el-form-item>
        <el-form-item label="物料工厂" prop="materialFactory">
          <el-input
            v-model="form.materialFactory"
            placeholder="请输入物料工厂"
          />
        </el-form-item>
        <el-form-item label="物料编号" prop="materialNumber">
          <el-input
            v-model="form.materialNumber"
            placeholder="请输入物料编号"
          />
        </el-form-item>
        <el-form-item label="成衣颜色" prop="garmentColor">
          <!-- <el-input v-model="form.garmentColor" placeholder="请输入成衣颜色" style="width: 350px"/> -->
          <el-input
            v-model="form.garmentColor"
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 10 }"
            placeholder="成衣颜色"
          ></el-input>
        </el-form-item>
        <el-form-item label="部位" prop="part">
          <el-input v-model="form.part" placeholder="请输入部位" />
        </el-form-item>
        <el-form-item label="用途" prop="purpose">
          <el-input v-model="form.purpose" placeholder="请输入用途" />
        </el-form-item>
        <el-form-item label="物料颜色" prop="materialColor">
          <el-input v-model="form.materialColor" placeholder="请输入物料颜色" />
        </el-form-item>
        <el-form-item label="物料色号" prop="colorCode">
          <el-input v-model="form.colorCode" placeholder="请输入物料色号" />
        </el-form-item>
        <el-form-item label="门幅" prop="width">
          <el-input v-model="form.width" placeholder="请输入门幅" />
        </el-form-item>
        <el-form-item label="克重" prop="weight">
          <el-input v-model="form.weight" placeholder="请输入克重" />
        </el-form-item>
        <el-form-item label="成份" prop="composition">
          <el-input v-model="form.composition" placeholder="请输入成份" />
        </el-form-item>
        <el-form-item label="规格" prop="specification">
          <el-input v-model="form.specification" placeholder="请输入规格" />
        </el-form-item>
        <el-form-item label="物料单价" prop="materialPrice">
          <el-input v-model="form.materialPrice" placeholder="请输入物料单价" />
        </el-form-item>
        <el-form-item label="单件用量" prop="unitQuantity">
          <el-input v-model="form.unitQuantity" placeholder="请输入单件用量" />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入单位" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      :title="title"
      :visible.sync="dialogVisible"
      width="500px"
      append-to-body
      v-if="dialogVisible"
    >
      <el-upload
        :action="Upload.url"
        :headers="Upload.headers"
        :limit="limit"
        :on-exceed="handleExceed"
        :on-success="handlePictureSuccessPic"
        :before-upload="beforeAvatarUpload"
        :file-list="fileLi"
        :on-change="changeFile1"
      >
        <el-button size="small" type="primary">导入文件</el-button>

        <!-- <i class="el-icon-plus"></i> -->
      </el-upload>

      <!-- <el-upload
      :on-error="uploadError"
      :accept="accept"
      class="uploadContent"
      :headers="header"
      :action="uploadurl"
      :on-remove="handleRemove"
      :before-remove="beforeRemove"
      multiple
      :limit="limit"
      ref="uploadComponent"
      :on-exceed="handleExceed"
      :auto-upload="autoupload"
      :file-list="fileList"
      :data="uploadData"
      :on-change="fileStateChange"
      :http-request="handleupload"
    >
      <span v-if="showtip">添加附件</span>
      <el-button class="btnColor2" size="small" type="primary">添加附件 </el-button>
    </el-upload> -->
    </el-dialog>
  </div>
</template>

<script>
import {
  listGarmentMetrialList,
  getGarmentMetrialList,
  delGarmentMetrialList,
  addGarmentMetrialList,
  updateGarmentMetrialList,
} from "@/api/shop/garmentMetrialList";
//--------导入token
import { getToken } from "@/utils/auth";
export default {
  name: "GarmentMetrialList",
  data() {
    return {
      //纵向滚动条
      tableHeight: "",
      limit: 2,
      Upload: {
        // 设置上传的请求头部
        headers: {
          header: { responseType: "blob" },

          Authorization: "Bearer " + getToken(),
        },
        // 图片上传的方法地址:
        url:
          process.env.VUE_APP_BASE_API + "/product/garmentMetrialList/import",
      },
      fileLi: [],
      dialogVisible: false,
      isOpen: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 成衣物料清单表格数据
      garmentMetrialListList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        status: null,
        primaryCategory: null,
        proNo: null,
        designNumber: null,
        productName: null,
        category: null,
        materialName: null,
        materialCategory: null,
        brand: null,
        season: null,
        year: null,
        expectedMonth: null,
        gender: null,
        version: null,
        releaseDate: null,
        standard: null,
        designer: null,
        materialFactory: null,
        materialNumber: null,
        garmentColor: null,
        part: null,
        purpose: null,
        materialColor: null,
        colorCode: null,
        width: null,
        weight: null,
        composition: null,
        specification: null,
        materialPrice: null,
        unitQuantity: null,
        unit: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    if (this.$route.query.proNo) {
      this.$set(this.queryParams, "proNo", this.$route.query.proNo);
    }
    this.getList();
  },
  mounted() {
    var _this = this;
    this.resizeTable();
    window.onresize = function () {
      _this.resizeTable();
    };
    // window.addEventListener("scroll", this.startScrollTimer);
  },
  // beforeDestroy() {
  //   window.removeEventListener("scroll", this.startScrollTimer);
  // },
  //记得清空  如果在keepalive中 则使用activated  deactivated
  destroyed() {
    window.onresize = null;
  },
  methods: {
    // table自动高度
    returnTableHeight(ref, bottomOffset) {
      let height = null;
      height =
        window.innerHeight - ref.getBoundingClientRect().top - bottomOffset;
      return height;
    },

    resizeTable() {
      this.$nextTick(() => {
        this.tableHeight = this.returnTableHeight(this.$refs.tableDom, 100);
      }, 0);
    },
    //图片上传前的相关判断
    beforeAvatarUpload(file) {
      // const isJPG = file.type == 'image/jpeg' || file.type == 'image/png';
      const isLt2M = file.size / 1024 / 1024 < 100;
      // if (!isJPG) {
      //     this.$message.error('上传头像图片只能是 JPG/PNG 格式!');
      // }
      if (!isLt2M) {
        this.$message.error("上传导入文件大小不能超过 100MB!");
      }
      this.openUploadLoading();
      return isLt2M;
    },
    //图片预览
    handlePictureCardPreview(file) {
      this.picUrl = file.url;
      this.imageUrl = file.url;
      // this.dialogVisible = true;
    },
    //部门文件导入修改打开
    daoru() {
      this.dialogVisible = true;
    },
    // 打开加载层
    openUploadLoading() {
      this.$modal.loading("正在导入，请稍候！");
    },
    //文件导入成功回传

    handlePictureSuccessPic(response, file) {
      if (response.code == 200) {
        this.dialogVisible = false;
        this.$modal.closeLoading();
        this.getList();
      }

      // this.openmsg = true;
      // this.msg = response.msg;

      //设置图片访问路径 （url 后台传过来的的上传地址）
      // this.picUrl = file.response.url;
      // const url = file.response.fileName;
      // this.file = file.response.url;
      // console.log(JSON.stringify(this.file));
      // if (res.code == 200) {

      //   this.dialogVisible = false

      //   if (res.msg == '操作成功') {

      //     this.$modal.msgSuccess('导入成功')
      //   } else {
      //     this.$modal.msgError(res.msg);
      //   }
      //   this.getList();
      //   // return true
      // } else {
      //   this.$modal.msgError(res.msg);
      //   this.dialogVisible = true
      //   // this.$message.msgError('该颜色未在字典定义')
      //   return
      // }
    },

    // 文件个数超出
    handleExceed() {
      this.$modal.msgError(`上传链接文件数量不能超过 ${this.limit} 个!`);
    },
    // 上传文件让第二次覆盖第一的文件
    changeFile1(file, fileList) {
      if (fileList.length > 1) {
        this.fileLi = fileList.slice(-1);

        // this.fileList = [fileList[fileList.length - 1]]//这一步，是 展示最后一次选择文件
      }
      // this.fileSpecial = fileList;
    },
    //搜索栏展示与收起
    shouqi() {
      // console.log(1);
      this.isOpen = !this.isOpen;
    },
    /** 查询成衣物料清单列表 */
    getList() {
      this.loading = true;
      listGarmentMetrialList(this.queryParams).then((response) => {
        this.garmentMetrialListList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        status: null,
        primaryCategory: null,
        proNo: null,
        designNumber: null,
        productName: null,
        category: null,
        materialName: null,
        materialCategory: null,
        brand: null,
        season: null,
        year: null,
        expectedMonth: null,
        gender: null,
        version: null,
        releaseDate: null,
        standard: null,
        designer: null,
        materialFactory: null,
        materialNumber: null,
        garmentColor: null,
        part: null,
        purpose: null,
        materialColor: null,
        colorCode: null,
        width: null,
        weight: null,
        composition: null,
        specification: null,
        materialPrice: null,
        unitQuantity: null,
        unit: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams = {};
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加成衣物料清单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getGarmentMetrialList(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改成衣物料清单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateGarmentMetrialList(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addGarmentMetrialList(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除成衣物料清单编号为"' + ids + '"的数据项？')
        .then(function () {
          return delGarmentMetrialList(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "product/garmentMetrialList/export",
        {
          ...this.queryParams,
        },
        `garmentMetrialList_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style scoped>
span.textname {
  display: -webkit-box;

  text-overflow: ellipsis;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
}

.el-input.is-disabled ::v-deep .el-input__inner {
  color: #606266;
  background-color: white;
  border: none;
}

.el-textarea.is-disabled ::v-deep .el-textarea__inner {
  color: #606266;
  background-color: white;
  border: none;
  width: 500px;
  resize: none;
  cursor: pointer;
}
</style>